#首页火车的业务
from pom.train_main_page import TrainMainPage
from pom.jump_page import JumpPage
import time

class MainTrainBuss():

    def __init__(self):
        self.trainMainPage=TrainMainPage()
        self.jumpPage=JumpPage()


    #输入单程出发站，到达站，日期，搜索按钮

    def oneWayTrain(self,departCity,arriveCity,departDate):
        self.jumpPage.verticalTrainButton()
        time.sleep(6)
        self.trainMainPage.sigle_trip().click()
        self.trainMainPage.dep_main_train_input().clear()
        self.trainMainPage.dep_main_train_input().send_keys(departCity)
        time.sleep(5)
        self.trainMainPage.arr_main_train_input().clear()
        self.trainMainPage.arr_main_train_input().send_keys(arriveCity)
        time.sleep(5)
        self.trainMainPage.dep_main_train_date().clear()
        self.trainMainPage.dep_main_train_date().send_keys(departDate)
        time.sleep(5)
        self.trainMainPage.inside_train().click()
        time.sleep(4)
        self.trainMainPage.search_button().click()

     #国内火车票--往返
    def insideRoundTrip(self,departCity,arriveCity,departDate,backDate):
        self.jumpPage.verticalTrainButton();
        self.trainMainPage.round_trip().click()
        time.sleep(2)
        self.trainMainPage.dep_main_train_input().clear()
        self.trainMainPage.dep_main_train_input().send_keys(departCity)
        time.sleep(2)
        self.trainMainPage.arr_main_train_input().clear()
        self.trainMainPage.arr_main_train_input().send_keys(arriveCity)
        time.sleep(2)
        self.trainMainPage.dep_main_train_date().clear()
        self.trainMainPage.dep_main_train_date().send_keys(departDate)
        time.sleep(2)
        self.trainMainPage.back_main_train_date().clear()
        self.trainMainPage.back_main_train_date().send_keys(backDate)
        time.sleep(2)
        self.trainMainPage.inside_train().click()
        time.sleep(2)
        self.trainMainPage.search_button().click()

    #国内火车--中转
    def insideHubTrip(self,departCity,arriveCity,departDate,hubCity):
        self.jumpPage.verticalTrainButton()
        self.trainMainPage.hub_trip().click()
        time.sleep(2)
        self.trainMainPage.dep_main_train_input().send_keys(departCity)
        time.sleep(2)
        self.trainMainPage.arr_main_train_input().send_keys(arriveCity)
        time.sleep(2)
        self.trainMainPage.dep_main_train_date().send_keys(departDate)
        time.sleep(2)
        self.trainMainPage.hub_station().send_keys(hubCity)

    #请输入出发城市名称
    def departCityName(self):
        return self.trainMainPage.depart_city_warn()

    #请输入到达城市名称
    def arriveCityName(self):
        return self.trainMainPage.arrive_city_warn()

    #请选择出发日期
    def departDate(self):
        return self.trainMainPage.select_date_warn()

    #请选择返回日期
    def backDate(self):
        return self.trainMainPage.select_back_date_warn()


    #刷新页面
    def refleshURL(self):
        self.trainMainPage.reflesh_url()








